# Contributor: Thomas Kienlen <kommander@laposte.net>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=scaleway-cli
pkgver=2.29.0
pkgrel=0
pkgdesc="Command-line client for Scaleway Cloud"
url="https://www.scaleway.com/en/cli"
arch="all !x86 !armv7 !armhf" # tests are failing for x86, armv7, armhf
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/scaleway/scaleway-cli/archive/refs/tags/v$pkgver.tar.gz"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
options="chmod-clean"
options="!check" # failing on the package builders

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -o scw ./cmd/scw/main.go
	PATH=. scw autocomplete script shell=bash > bashcomp
	PATH=. scw autocomplete script shell=fish > fishcomp
	PATH=. scw autocomplete script shell=zsh > zshcomp
}

check() {
	go test -v ./...
}

package() {
	install -Dm755 scw "$pkgdir"/usr/bin/scw

	install -Dm644 bashcomp "$pkgdir"/usr/share/bash-completion/completions/scw
	install -Dm644 fishcomp "$pkgdir"/usr/share/fish/vendor_completions.d/scw.fish
	install -Dm644 zshcomp "$pkgdir"/usr/share/zsh/site-functions/_scw

}

sha512sums="
0391d089565156f06fa779283e95591240814249e2275b3b098bac7037c36f906d4e04b4b7b7d2fbc28416dfb691ce0c553518bae45688a2e57e4d6a40a605fd  scaleway-cli-2.29.0.tar.gz
"
